<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <script language="JavaScript">
        if (window != top)
            top.location.href = "<%=request.getContextPath()%>/login.jsp";
    </script>
    <meta charset="utf-8">
    <title>五指山农污远程监控平台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/images/favicon.ico"/>
    <link href="<%=request.getContextPath()%>/css/logincss/bootstrap.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/css/cas/cas.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/css/logincss/layout.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/css/logincss/global.css" rel="stylesheet">
    <style>
        img {
            max-width: 100%;
        }
        .clear:after {
            content: "";
            width: 0;
            height: 0;
            font-size: 0;
            clear: both;
            overflow: hidden;
            display: block;
            visibility: hidden;
        }

        .lt {
            float: left;
            /*margin-top: 50px;*/
            /*margin-bottom: 50px;*/
            width: 331px;
            /*height: 276px;*/
            border-right: 1px solid rgba(0, 220, 250, 0.1);
        }
        .rt {
            position: relative;
            float: right;
            margin: 0;
            width: 368px;
            height: 366px;
        }
        .rowbox {
            width: 331px;
        }

        .lbox1 {
            float: left;
            margin: 20px 0 0 40px;
            color: #d3e7f7;
            font-size: 14px;
        }

        .lbox2 {
            float: right;
            margin-right: 40px;
            margin-top: 22px;
            margin-bottom: 0px;
            color: #53718d;
            font-size: 12px;
            position: relative;
        }

        .lbox3 {
            float: left;
            width: 251px;
            height: 24px;
            color: #53718d;
            font-size: 14px;
            text-decoration: none;
            margin: 10px 40px 0px 40px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
        }

        .lbox3:hover {
            color: #00dcfa;
        }

        .lbox4 {
            float: right;
            margin-right: 40px;
            margin-top: 22px;
            margin-bottom: 0px;
            color: #53718d;
            font-size: 12px;
            text-decoration: none;
            position: relative;
        }

        .lbox4:hover {
            color: #00dcfa;
        }

        .notice-none {
            color: #53718d;
            font-size: 14px;
            margin: 20px 0 0 40px;
        }

        .box {
            border: 1px;
        }

        .boxLeft {
            margin-top: 30px;
            /*margin-left: 134px;*/
            margin-bottom: 0;
            /*width: 100px;*/
            height: 50px;
            font-size:20px;
            color: #53718d;
        }


        #login {
            position: fixed;
            left: 50%;
            top: 40%;
            margin-left: -350px;
            margin-top: -233px;
            width: 700px;
            height: 366px;
            background-image: url("<%=request.getContextPath()%>/jsp/login/loginbg.png");
            background-repeat: no-repeat;
            background-position: center;
            background-size: 100% 100%;
            /*background-color: #fff;
            border-radius: 9px;*/
        }

        .boxcenter {
            width: 1920px;
            height: 900px;
            position: absolute;
            left: 50%;
            top: 50%;
            margin: auto;
            margin-left: -960px;
            margin-top: -450px;
        }

        .logofont {
            margin-left: 48px;
            color: #22abd8;
            font-size: 25px;
            font-family: Microsoft YaHei;
        }

        .checkbox1 {
            margin-left: 47px;
            padding: 15px;
            width: 20px;
            height: 20px;
            background-color: #fff;
            border: 1px;
        }
    </style>
</head>
<body id="cas" style="background:url(<%=request.getContextPath()%>/huazhi/login/cubebg.png) #020b1d; background-repeat: no-repeat;background-position: center;">
<div id="container">
<div class="box" id="login">
    <div class="lt">
        <div class="notice-none" style="margin:10px;margin-top: 15px;margin-left: 18px;">
            <img src="<%=request.getContextPath()%>/huazhi/login/login-3.png" style="width: 340px;height: 335px;">
        </div>
    </div>
    <div class="rt">
        <div class="boxLeft" style="text-align: center">五指山农污远程监控平台</div>
        <form  id="fm1" action="<%=request.getContextPath()%>/rest/login" method="post" onsubmit="return check()">
            <section class="row">
                <input  type="text" name="username" class="required" placeholder="用户名" id="LAY-user-login-username">
            </section>
            <section class="row">
                <input  type="password" name="password" class="required" placeholder="密码" id="LAY-user-login-password">
            </section>
            <section class="row" style="margin-bottom: 50px;position:absolute;">
                <input class="btn-submit" name="submit" accesskey="l" value="登录" tabindex="4" type="submit" style="margin-top: 40px;">
            </section>
        </form>
    </div>
</div>
</div>
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.all.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/lib/cas/js/cas.js"></script>
<link href="<%=request.getContextPath()%>/huazhi/login/jquery.confirm.css" rel="stylesheet">
<script src="<%=request.getContextPath()%>/huazhi/login/jquery-confirm.js"></script>
<script>
    function check() {
        var username = $("#LAY-user-login-username").val();
        var password = $("#LAY-user-login-password").val();
        if (username == "") {
            var usernames = document.getElementById("LAY-user-login-username");
            usernames.setAttribute("class", "layui-input layui-form-danger");
            usernames.focus();
            layui.layer.tips('请输入用户名', '#LAY-user-login-username', {
                tips: 2
            });
            return false;
        }
        if (password == "") {
            var passwords = document.getElementById("LAY-user-login-password");
            passwords.setAttribute("class", "layui-input layui-form-danger");
            passwords.focus();
            layui.layer.tips('请输入密码', '#LAY-user-login-password', {
                tips: 2
            });
            return false;
        }
        var flag = true;
        $.ajax({
            type: "post",
            url: "<%=request.getContextPath()%>/rest/getCheckByUserNamePassword",
            data: "username=" + username + "&password=" + password,
            dataType: "json",
            async: false,
            success: function (data) {
                if(data.success == false){
                    return false;
                }else{
                    if (data == "0") {
                        layui.layer.tips('用户名错误', '#LAY-user-login-username', {
                            tips: 2
                        });
                        flag = false;
                        return false;
                    } else if (data == "1") {
                        layui.layer.tips('用户已被禁用', '#LAY-user-login-username', {
                            tips: 2
                        });
                        flag = false;
                        return false;
                    }  else if (data == "2") {
                        layui.layer.tips('密码错误', '#LAY-user-login-password', {
                            tips: 2
                        });
                        flag = false;
                        return false;
                    } else {
                        flag = true;
                        return false;
                    }
                }

            },
        })
        if (flag) {
            return true;
        } else {
            return false;
        }
    }

</script>

</body>
</html>